package com.example.doudizhu;

import java.util.ArrayList;
import java.util.Collections;
import java.util.function.Consumer;

public class PokerGame1 {//new该对象表示开始一局游戏

    static ArrayList<String> list = new ArrayList<>();

    //生成牌堆
    static {
        String[] color = {"♠", "♥", "♣", "♦"};
        String[] num = {"3,", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2"};

        for (String col : color) {
            for (String n : num) {
                String s = col + n;
                list.add(s);
            }
        }
        list.add("小王");
        list.add("大王");
    }


    public PokerGame1() {
        //洗牌
        Collections.shuffle(list);
        //发牌
        ArrayList<String> lord = new ArrayList<>();
        ArrayList<String> player1 = new ArrayList<>();
        ArrayList<String> player2 = new ArrayList<>();
        ArrayList<String> player3 = new ArrayList<>();
        for (int i = 0; i < list.size(); i++) {
            String temp = list.get(i);
            if (i<=2) lord.add(temp);
            else {
                if (i%3==0)player1.add(temp);
                else if (i%3==1) {
                    player2.add(temp);
                }else {
                    player3.add(temp);
                }
            }
        }
        //看牌
        lookpoker("底牌",lord);
        lookpoker("玩家1",player1);
        lookpoker("玩家2",player2);
        lookpoker("玩家3",player3);

    }

    void lookpoker(String name,ArrayList<String> pokers){
        System.out.print(name+" :");
        pokers.forEach(new Consumer<String>() {
            @Override
            public void accept(String s) {
                System.out.print(s+" ");
            }
        });
        System.out.println();
    }

}
